import { getHomeCategories, getHotSuggests, getHouseList } from "@/services/modules/home";
import { defineStore } from "pinia";

const useHomeStore = defineStore("home", {
  state: () => ({
    hotSuggests: [],
    currentPage:1,
    categories:[],
    houselist:[]
  }),
  actions: {
    async fetchHotSuggestsAction() {
      const res = await getHotSuggests();
      // console.log(res.data)
      this.hotSuggests = res.data;
    },
    async fetchHomeCategoriesAction() {
      const res = await getHomeCategories();
      this.categories = res.data;
    },
    async fetchHouseListAction() {
      const res = await getHouseList(this.currentPage);
      this.houselist= [...this.houselist, ...res.data]
      this.currentPage++;
    }
  }
})
export default useHomeStore
